Computer systems often define several address spaces to store various types or classes of data. For example, executable instructions may be stored in a code segment, while non-executable data may be stored in a data segment. Sometimes address spaces overlap, so that the same data may be referenced through two different addresses; other address spaces are entirely distinct, so that data located within one address space does not appear anywhere within the other space.
Separate (or separable) address spaces provide a powerful programming tool, and serve as a foundation for many advanced computing paradigms. Pre-emptive multitasking and virtual memory systems depend on hardware that permits the establishment of separate, protected memory spaces. Each process or thread in such a system can be provided with an execution environment that appears to contain memory and other resources dedicated solely to that process. An operating system (“OS”) keeps track of the physical resources in the system (e.g. memory and devices) and arranges for the hardware to translate virtual addresses (“VA”) used by the processes and threads into physical addresses (“PA”) that the hardware can use.
Virtual machine systems add another level of abstraction to this model. In some virtual machine systems, low-level software called a “hypervisor” controls the system's physical resources and uses virtualization features of the processor(s) to create one or more virtual machines, each of which appears to be an independent computer with its own physical resources. A “guest” operating system can be started on each of these virtual machine. The guest OS manages the resources supplied by the hypervisor and doles them out to processes and/or threads running under the guest OS.
Several different address spaces are present in this three-level virtual machine model. At the lowest level, the hypervisor deals with physical addresses of real resources present in the host system—“Host Physical Addresses” (“HPA”). The guest OSs are presented with virtual resources that the hypervisor has arranged at locations within the address space of a virtual machine. Each guest OS uses “guest physical addresses” (“GPA”) to refer to these resources. Finally, the guest OS prepares virtual execution environments for its threads and processes; the threads and processes use virtual addresses (“VA”) to refer to resources the guest OS has allocated to them.
Modern central processing units (“CPUs”) contain dedicated circuitry to translate between these addresses, so that a thread or process can quickly access data stored in a physical memory, when the thread has only a virtual address of the data. However, peripheral hardware units may not have ready access to these translation facilities, so it may be difficult or time-consuming for a non-CPU hardware device to access data stored in a physical memory when the software task controlling the device cannot provide a HPA. This situation may arise in the virtual machine environment described: a guest OS may only be able to provide GPAs to a peripheral, but the peripheral needs a HPA to transfer data to or from the intended memory location (such a transfer from device to memory is called a direct memory access, or “DMA.”)